package com.yixin.consumer.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class PublisherController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/hello")
    public Object hello() {
        rabbitTemplate.convertAndSend("simple.queue", "hello,spring amqp!");
        new Thread(new Runnable() {
            @Override
            public void run() {
                rabbitTemplate.convertAndSend("simple.queue", "在线程里面");
                log.info("hello");
            }
        }, "hello").start();
        log.info("faxioasx");
        return "hello";
    }
}
